1. /* slmlsadd.cpp by K.Tsuru */
  2. // function ID = 232 DRADIX, BRADIX
  3. /*******************************************************************
  4. SLong, SIntefer class
  5. It adds a small positive value to the abusolute value implemented
  6. for radix conversion.
  7. *******************************************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. void SLong::LsAdd(fType a){
  12. if(!a) return;
  13. fType rdx = Radix();
  14. int norm = 0; //It is necessary to normalize or not.
  15. if(Sign(232) == 0) SetSign(1); //It also checks the allocation of memory.
  16. if(a <= BRADIX){ // figure[0] + a < fTypeMax = USHRT_MAX
  17. figure[0] += a;
  18. if(figure(0) >= rdx) norm = 1;
  19. } else{
  20. ulong u = (ulong)figure(0) + (ulong)a;
  21. figure[0] = fType(u%rdx);
  22. figure[1] += fType(u/rdx);
  23. if(figure(1) >= rdx) norm = 1;
  24. if(!aHead) aHead = 1u; //The figure increases to two from one.
  25. }
  26. aTail = 0;
  27. while(!figure(aTail)) aTail++;
  28. if(norm) Normalize(); //normalization
  29. }

slmlsadd.cpp : last modifiled at 2017/03/13 14:32:01(983 bytes)
created at 2017/10/07 10:26:49
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).